package xin.ssm.jxc.servicesImpl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import xin.ssm.jxc.dao.UsersMapper;
import xin.ssm.jxc.model.Users;
import xin.ssm.jxc.services.IUsersService;
@Service
public class UsersService implements IUsersService {
	@Resource
	private UsersMapper usersMapper;
	//查找用户，通过主键
	@Override
	public Users findUserByPrimaryKey(String userLoginName) {
		//返回一个User对象或空
		return usersMapper.selectByPrimaryKey(userLoginName);	
	}
	//根据字段选择性添加
	@Override
	public int addUserSelective(Users u) {
		// TODO Auto-generated method stub
		return usersMapper.insertSelective(u);
	}
	//普通用户登录
	@Override
	public Users findUserByNameAndPwd(Users u) {
		// TODO Auto-generated method stub
		return usersMapper.selectByNameAndPassword(u);
	}
	//查询普通用户
	@Override
	public List<Users> findCommonUser(String type) {
		// TODO Auto-generated method stub
		return usersMapper.selectAllUserByType(type);
	}
	//删除普通用户
	@Override
	public int deleteUser(String username) {
		// TODO Auto-generated method stub
		return usersMapper.deleteByPrimaryKey(username);
	}
	//修改普通用户
	@Override
	public int updateteUser(Users u) {
		// TODO Auto-generated method stub
		return usersMapper.updateByPrimaryKeySelective(u);
	}
	//动态查询所有普通用户
	@Override
	public List<Users> findUserDynamic(Users u) {
		// TODO Auto-generated method stub
		return usersMapper.findUserDynamic(u);
	}
	
	
}
